/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pe.siass.test;

import com.pe.siass.beans.ParametrosBean;
import com.pe.siass.dao.ParametroDao;
import com.pe.siass.utils.USqlMapLoader;
import java.io.IOException;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 *
 * @author Hrengifo
 */
public class Main3 {
 private Object ParametrosBean;
 private SqlSessionFactory sqlSessionFactory = null;

   public Main3() throws IOException {
        sqlSessionFactory =  USqlMapLoader.getInstance().getSession();
    }


   public void xxx(){
    try{
    //USqlMapLoader uSqlMapLoader = USqlMapLoader.getInstance();
    //SqlSessionFactory sqlSessionFactory = USqlMapLoader.getInstance().getSession();

    SqlSession sqlSession = sqlSessionFactory.openSession();
 

         //  paux.setParNombre("HENRY");

      //System.out.println("INSERTAR ==> "+ParametroDao.insertParametros(paux, sqlSession));

    //  paux.setIpModificacion("HRENGIFO");

    ParametroDao  parametroDao = new ParametroDao();

     ParametrosBean bu = new ParametrosBean();
      ParametrosBean paux = new ParametrosBean();
    // bu.setParNombre("HENRY");
    // bu.setStRegistro("1");
     bu.setParValor("1");
     bu.setParEquivalente("1");
     
      List<ParametrosBean> xx = parametroDao.selectParametros(bu, sqlSession);

        for (ParametrosBean c2: xx)
       {
             System.out.println(c2.getParDescripcion()+ " " + c2.getParNombre());
             paux = c2;
           // log.info("Contact name: " + c.getFirstName() + " " + c.getLastName());
       }

           System.out.println(paux.getCreadoPor());
      System.out.println(paux.getFechaCreacion());
      System.out.println(paux.getIpCreacion());
      System.out.println(paux.getParDescripcion());
      System.out.println(paux.getParEquivalente());
      System.out.println(paux.getParNombre());
      System.out.println(paux.getParValor());
      System.out.println(paux.getStRegistro());

      paux.setIpModificacion("192.168.1.1");
      paux.setModificadoPor("XXXX");

      System.out.println("UPDATE ==> "+parametroDao.updateParametros(paux, sqlSession));

     sqlSession.commit();



    }catch(Exception e){
        e.printStackTrace();
    }
    }

   public static void main (String ar []){
       try{
            Main3 xx = new Main3();
            xx.xxx();
       }
        catch(Exception e){
        e.printStackTrace();
    }
   }

}
